package org.example.controller;

import org.example.entity.User;
import org.example.service.RedisService;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

/**
 * TODO 类功能介绍及重点或容易混淆点的说明。
 *
 * @version 1.0 2023/5/20 10:55 龙小南 新建类[说明]
 * @author: 龙小南
 * @Date: 2023/5/20 10:55
 * @Version 1.0[当前版本号]
 */

@RestController
@RequestMapping("/redis")
public class RedisController {
    private final RedisService redisService;

    public RedisController(RedisService redisService) {
        this.redisService = redisService;
    }

    @GetMapping("/{key}")
    public Mono<String> getValue(@PathVariable String key){
        return redisService.getValue(key);
    }

    @PostMapping("/")
    public Mono<Boolean> setValue(@RequestBody User user){
        return redisService.setValue(String.valueOf(user.getId()), user.getName());
    }
}
